Neuridion API Reference
Complete reference for all 37 standard library modules.
Core
Data & Storage
Files & Network
User Interface
Text & Language
Date, Time & Security
AI, Media & Hardware
Core
Global functions available without a module prefix.
| Function | Parameters | Returns | Description |
Print() | values... | — | Output text to the console |
TypeOf() | value | String | Get the type name of a value |
Array() | items... | Array | Create an array from arguments |
IsNil() | value | Boolean | Check if a value is Nil |
Core.UUID() | — | String | Generate a random UUID string |
Math
Mathematical functions, constants, and random number generation.
Properties
| Property | Type | Description |
Math.PI | Double | Pi (3.14159...) |
Math.E | Double | Euler's number (2.71828...) |
Math.Infinity | Double | Positive infinity |
Math.NaN | Double | Not a Number |
Methods
| Method | Parameters | Returns | Description |
Sqrt(x) | number | Double | Square root |
Sin(x) | radians | Double | Sine |
Cos(x) | radians | Double | Cosine |
Tan(x) | radians | Double | Tangent |
Asin(x) | value | Double | Arc sine |
Acos(x) | value | Double | Arc cosine |
Atan(x) | value | Double | Arc tangent |
Atan2(y, x) | y, x | Double | Two-argument arc tangent |
Log(x) | number | Double | Natural logarithm |
Log10(x) | number | Double | Base-10 logarithm |
Exp(x) | number | Double | e raised to x |
Pow(base, exp) | base, exponent | Double | Power |
Floor(x) | number | Double | Round down |
Ceil(x) | number | Double | Round up |
Round(x [, decimals]) | number [, places] | Double | Round to nearest (optional decimal places) |
Abs(x) | number | Number | Absolute value |
Min(a, b) | a, b | Number | Smaller of two |
Max(a, b) | a, b | Number | Larger of two |
Sign(x) | number | Integer | Sign: -1, 0, or 1 |
Random() | — | Double | Random 0.0–1.0 |
RandomInt(min, max) | min, max | Integer | Random integer in range |
System
System information and process control.
Properties
| Property | Type | Description |
System.Platform | String | Always "macOS" |
System.OSVersion | String | macOS version string |
System.UserName | String | Current user name |
Methods
| Method | Parameters | Returns | Description |
Sleep(ms) | milliseconds | — | Pause execution |
Exit([code]) | [exit code] | — | Terminate the program |
Environment(name) | variable name | String | Read environment variable |
CurrentTimeMillis() | — | Integer | Milliseconds since epoch |
Console
Console I/O for reading input and writing formatted output.
| Method | Parameters | Returns | Description |
Write(values...) | values | — | Print without newline |
WriteLine(values...) | values | — | Print with newline |
Error(msg) | message | — | Print [ERROR] message (red) |
Warn(msg) | message | — | Print [WARN] message (orange) |
Info(msg) | message | — | Print [INFO] message (blue) |
Debug(msg) | message | — | Print [DEBUG] message (gray) |
Table(data) | 2D array | — | Print formatted table |
ReadLine([prompt]) | [prompt text] | String | Read user input |
Clear() | — | — | Clear console output |
JSON
Parse, create, and manipulate JSON data.
| Method | Parameters | Returns | Description |
Parse(text) | JSON string | Object/Array | Parse JSON string to value |
Stringify(value [, pretty]) | value [, Boolean] | String | Convert value to JSON string |
IsValid(text) | string | Boolean | Check if string is valid JSON |
Format(text) | JSON string | String | Pretty-print JSON |
ReadFile(path) | file path | Object/Array | Load and parse a JSON file |
WriteFile(path, value [, pretty]) | path, value [, Bool] | — | Write value as JSON to file |
CSV
Read and write CSV (Comma-Separated Values) data.
| Method | Parameters | Returns | Description |
Parse(text [, delimiter]) | CSV string [, separator] | Array | Parse CSV string to 2D array |
Read(path [, delimiter]) | file path [, separator] | Array | Read CSV file to 2D array |
Write(path, data [, delimiter]) | path, 2D array [, separator] | — | Write 2D array to CSV file |
ToString(data [, delimiter]) | 2D array [, separator] | String | Convert 2D array to CSV string |
XML
Parse, create, and manipulate XML documents.
| Method | Parameters | Returns | Description |
ParseString(text) | XML string | XmlDocument | Parse XML string |
LoadFromFile(path) | file path | XmlDocument | Load XML from file |
Create(rootName) | root element name | XmlDocument | Create new XML document |
XmlDocument Object
| Method | Returns | Description |
.GetRootElement() | XmlElement | Get the root element |
.ToString() | String | Serialize to XML string |
.SaveToFile(path) | — | Save to file |
XmlElement Object
| Method/Property | Returns | Description |
.Name | String | Element tag name |
.TextContent | String | Text content |
.GetChildren() | Array | Get child elements |
.GetChildByName(name) | XmlElement | Find child by tag name |
.GetAttribute(name) | String | Get attribute value |
.SetAttribute(name, value) | — | Set attribute |
.SetTextContent(text) | — | Set text content |
.AddChild(element) | — | Append child element |
.RemoveChild(element) | — | Remove child element |
Database
SQLite database access.
| Method | Parameters | Returns | Description |
Open(path) | file path | Connection | Open or create a SQLite database |
InMemory() | — | Connection | Create in-memory database |
Connection Object
| Method | Parameters | Returns | Description |
.Execute(sql, params...) | SQL [, values] | Integer | Execute SQL, return affected rows |
.Query(sql, params...) | SQL [, values] | Array | Query and return rows as array of objects |
.Scalar(sql, params...) | SQL [, values] | Value | Return first column of first row |
.Close() | — | — | Close the connection |
.TableExists(name) | table name | Boolean | Check if table exists |
.LastInsertId() | — | Integer | Last inserted row ID |
.Changes() | — | Integer | Rows changed by last statement |
Storage
Persistent key-value storage (per project).
| Method | Parameters | Returns | Description |
Set(key, value) | key, value | — | Store a value |
Get(key) | key | Value | Retrieve a stored value |
Has(key) | key | Boolean | Check if key exists |
Remove(key) | key | — | Delete a stored value |
GetAll() | — | Object | Get all key-value pairs |
Clear() | — | — | Delete all stored values |
RegEx
Regular expression matching and manipulation.
| Method | Parameters | Returns | Description |
IsMatch(pattern, text) | pattern, text | Boolean | Test if text matches pattern |
Match(pattern, text) | pattern, text | Array | Return all matches |
Replace(pattern, text, replacement) | pattern, text, replacement | String | Replace matches |
Split(pattern, text) | pattern, text | Array | Split text by pattern |
Escape(text) | text | String | Escape special regex characters |
FileAndFolder
File system operations: read, write, copy, move, and browse files and folders.
Properties
| Property | Description |
HomeDirectory | User home directory |
TempDirectory | Temporary directory |
DesktopDirectory | Desktop path |
DocumentsDirectory | Documents path |
DownloadsDirectory | Downloads path |
CurrentDirectory | Current working directory |
Methods
| Method | Parameters | Returns | Description |
ReadFile(path) | path | String | Read entire file as text |
WriteFile(path, text) | path, content | — | Write text to file |
AppendLine(path, text) | path, line | — | Append a line to file |
FileExists(path) | path | Boolean | Check if file exists |
DeleteFile(path) | path | — | Delete a file |
CopyFile(src, dst) | source, destination | — | Copy a file |
MoveFile(src, dst) | source, destination | — | Move a file |
RenameFile(path, newName) | path, new name | — | Rename a file |
GetFileSize(path) | path | Integer | File size in bytes |
Open(path) | path | FileHandle | Open file for read/write |
CreateFolder(path) | path | — | Create directory |
DeleteFolder(path) | path | — | Delete directory |
FolderExists(path) | path | Boolean | Check if folder exists |
ListFiles(path) | directory path | Array | List files in directory |
ListFolders(path) | directory path | Array | List subdirectories |
ListAll(path) | directory path | Array | List all items |
GetFileName(path) | path | String | Extract file name |
GetExtension(path) | path | String | Extract file extension |
GetDirectory(path) | path | String | Extract parent directory |
Combine(path1, path2) | base, relative | String | Join paths |
ChooseFile([filter]) | [extension filter] | String | Show file picker dialog |
ChooseFolder() | — | String | Show folder picker dialog |
FileHandle Object
| Method/Property | Returns | Description |
.Path | String | File path |
.IsOpen | Boolean | Whether file is open |
.ReadAll() | String | Read entire file |
.ReadLine() | String | Read next line |
.Write(text) | — | Write text (overwrite) |
.Append(text) | — | Append text |
.Close() | — | Close the file |
Network
HTTP requests, TCP connections, and sessions.
| Method | Parameters | Returns | Description |
Get(url [, headers]) | URL [, Object] | Response | HTTP GET request |
Post(url, body [, headers]) | URL, body [, Object] | Response | HTTP POST request |
Put(url, body [, headers]) | URL, body [, Object] | Response | HTTP PUT request |
Delete(url [, headers]) | URL [, Object] | Response | HTTP DELETE request |
Download(url, path) | URL, file path | Boolean | Download file to disk |
Session() | — | Session | Create persistent session |
TCP.Connect(host, port [, timeout]) | host, port [, seconds] | TCPConnection | Open TCP connection |
Response Object
| Property | Type | Description |
.StatusCode | Integer | HTTP status code |
.Body | String | Response body |
.OK | Boolean | True if 200-299 |
.Headers | Object | Response headers |
Compression
Zip/unzip files and folders.
| Method | Parameters | Returns | Description |
ZipFolder(folder, zipPath) | source folder, output zip | Boolean | Compress a folder |
ZipFile(file, zipPath) | source file, output zip | Boolean | Compress a single file |
Unzip(zipPath, folder) | zip file, output folder | Boolean | Extract entire archive |
UnzipFile(zipPath, fileName, outPath) | zip, file name, output | Boolean | Extract single file |
ListArchiveContent(zipPath) | zip file | Array | List files in archive |
CompressBytes(data [, algo]) | string [, algorithm] | String | Compress data in memory |
DecompressBytes(data [, algo]) | string [, algorithm] | String | Decompress data in memory |
Email
Send and receive email via SMTP and IMAP.
| Method | Parameters | Returns | Description |
Send(to, subject, body [, from, html]) | to, subject, body [, from, html] | Boolean | Send email via SMTP |
Create() | — | Mail | Create composable email |
SMTP(host, port, user, pass) | credentials | SMTP | Create SMTP connection |
IMAP(host, port, user, pass) | credentials | IMAP | Create IMAP connection |
Mail Object
| Property/Method | Description |
.From, .To, .CC, .BCC | Address fields |
.Subject, .Body, .HTML | Content fields |
.AddAttachment(path) | Attach a file |
.Send() | Send the email |
Create native macOS windows and dialogs with controls, shapes, and callbacks.
| Method | Parameters | Returns | Description |
Window(title, width, height [, options]) | title, w, h [, Object] | FormWindow | Create a form window |
InputBox(prompt [, title [, default]]) | String [, String [, String]] | String | Simple input dialog |
MsgBox(message [, title [, style]]) | String [, String [, Integer]] | Integer | Message dialog |
FormWindow Controls
All controls use unified signature: Add*(name, x, y [, {options}]). Content (text, items, value) goes into the options dict.
| Method | Key Options | Description |
.AddLabel() | "Text", "FontSize", "FontBold" | Static text label |
.AddButton() | "Text", "Style", "OnClick", "OnRightClick" | Clickable button |
.AddTextField() | "Text", "Placeholder", "Password", "OnChange", "OnFocus", "OnBlur" | Single-line text input |
.AddTextArea() | "Text", "OnChange", "OnFocus", "OnBlur" | Multi-line text input |
.AddCheckBox() | "Text", "Checked", "OnChange" | Checkbox toggle |
.AddRadioButton() | "Text", "Selected", "OnChange" | Radio button |
.AddComboBox() | "Items", "OnChange" | Dropdown selection |
.AddListBox() | "Items", "OnChange", "OnDoubleClick", "OnSelect" | Scrollable list |
.AddProgressBar() | "Value" | Progress indicator |
.AddSlider() | "Value", "OnChange" | Slider control |
.AddTable() | "Data", "HasHeaders", "Editable", "OnDoubleClick", "OnSelect" | Data table |
.AddCanvas() | "Image", "SystemImage", "OnClick", "OnMouseMove", "OnPaint", "OnRightClick" | Image/drawing canvas |
.AddGroupBox() | "Text" | Group container |
.AddTabControl() | "Tabs", "Position", "SelectedTab", "OnChange", "OnDoubleClick", "OnRightClick" | Tab container with named tabs |
.AddSeparator() | "Width" | Horizontal separator |
.AddDatePicker() | "Value", "Style", "Mode", "MinDate", "MaxDate", "OnChange", "OnClick", "OnDoubleClick", "OnRightClick" | Date/time picker |
.AddToolbar() | "Items", "Style" | Native macOS toolbar in window title bar |
ForegroundColor Option
All text controls (Label, Button, TextField, TextArea, CheckBox, RadioButton) support an optional "ForegroundColor" option to set the text color:
win.AddLabel("lbl", 10, 10, {"Text": "White text", "ForegroundColor": Color.RGB(255, 255, 255)})
Also settable at runtime via GetControl: win.GetControl("lbl").ForegroundColor = Color.RGB(255, 0, 0)
DatePicker Control
Native date/time picker that integrates with the DateAndTime module:
// Compact date picker (default)
win.AddDatePicker("dp1", 10, 50, {"Value": DateAndTime.Now(), "Style": "Compact"})
// Calendar popup picker
win.AddDatePicker("dp2", 10, 80, {"Value": DateAndTime.Create(2026, 1, 1), "Style": "Calendar"})
// Time-only picker
win.AddDatePicker("dp3", 10, 110, {"Mode": "Time"})
// Date+Time picker
win.AddDatePicker("dp4", 10, 140, {"Mode": "DateTime"})
| Option | Type | Description |
"Value" | DateAndTime object | Initial date value (default: current date) |
"Style" | String | "Compact" (text field + stepper, default) or "Calendar" (graphical calendar) |
"Mode" | String | "Date" (default), "DateTime", or "Time" |
"MinDate" | DateAndTime object | Minimum selectable date |
"MaxDate" | DateAndTime object | Maximum selectable date |
"OnChange" | Function | Fires when date changes. event["Value"] = DateAndTime object |
"OnClick" | Function | Fires on click. event["Value"] = current DateAndTime object |
"OnDoubleClick" | Function | Fires on double-click. event["Value"] = current DateAndTime object |
"OnRightClick" | Function | Fires on right-click |
GetControl returns a DateAndTime object for .Value: Var date As Object = win.GetControl("dp1").Value — with Year, Month, Day, Hour, Minute, Second, Format() etc.
TabControl
A tabbed container that organizes controls into switchable tab pages. Returns an object with its own Add*() methods for placing controls inside specific tabs.
Var tabs As Object = app.AddTabControl("tabs", 10, 10, {
"Tabs": ["General", "Advanced", "About"],
"Width": 400, "Height": 300,
"OnChange": onTabChanged
})
// Add controls to specific tabs using the "Tab" option (0-based index)
tabs.AddLabel("lblName", 10, 10, {"Text": "Name:", "Tab": 0})
tabs.AddTextField("txtName", 80, 8, {"Width": 200, "Tab": 0})
tabs.AddCheckBox("chkDebug", 10, 10, {"Text": "Debug Mode", "Tab": 1})
tabs.AddSlider("sldSpeed", 10, 40, {"Value": 50, "Tab": 1})
tabs.AddLabel("lblVersion", 10, 10, {"Text": "Version 1.0", "Tab": 2})
| Option | Type | Description |
"Tabs" | Array | Array of tab names (strings) |
"Position" | String | Tab header position: "Top" (default), "Bottom", "Left", "Right", "None" |
"SelectedTab" | Integer | Initially selected tab index (0-based, default: 0) |
"OnChange" | Function | Fires when tab is switched. event["Value"] = new tab index, event["TabIndex"] = index, event["TabName"] = tab label |
"OnDoubleClick" | Function | Fires on double-click on a tab header. event["TabIndex"] = index, event["TabName"] = tab label |
"OnRightClick" | Function | Fires on right-click on a tab header. event["TabIndex"] = index, event["TabName"] = tab label |
"Tab" | Integer | On child controls: which tab page to place the control on (0-based) |
Child controls use tab-relative coordinates (x/y relative to the tab content area, not the window). Access child controls normally via win.GetControl("txtName"). Set the active tab programmatically: win.GetControl("tabs").SelectedTab = 2
Toolbar
Adds a native macOS toolbar to the window title bar. The toolbar appears in the standard macOS position (integrated into the title bar area) and supports buttons, search fields, separators, and flexible spaces.
Note: AddToolbar uses a special signature: AddToolbar(name, {options}) — no x/y coordinates since the toolbar is always in the title bar.
Var app As Object = Form.Window("My App", 600, 400)
Function onNew(sender As Object, event As Object)
Print("New clicked!")
End Function
Function onSearch(sender As Object, event As Object)
Print($"Search: {event["Value"]}")
End Function
app.AddToolbar("toolbar", {
"Items": [
{"Name": "new", "Label": "New", "Icon": "plus", "Type": "button", "OnClick": onNew},
{"Name": "save", "Label": "Save", "Icon": "square.and.arrow.down", "Type": "button", "OnClick": onSave},
"separator",
"flexibleSpace",
{"Name": "search", "Label": "Search", "Type": "search", "Placeholder": "Search...", "OnChange": onSearch}
],
"Style": "unified"
})
app.Show()
| Option | Type | Description |
"Items" | Array | Array of toolbar item definitions (dicts or strings) |
"Style" | String | "unified" (default), "unifiedCompact", or "expanded" |
Item types:
| Type | Keys | Description |
"button" | Name, Label, Icon, OnClick | Clickable toolbar button with SF Symbol icon |
"search" | Name, Label, Placeholder, OnChange | Search field (NSSearchToolbarItem) |
"separator" | — | Use the string "separator" in the Items array |
"flexibleSpace" | — | Use the string "flexibleSpace" to push items to the right |
Toolbar button clicks fire with event["Value"] = item name. Search field changes fire with event["Value"] = current search text.
Context Menu
Any control can have a right-click context menu. Add a "ContextMenu" option to the control's options dict with an array of menu items:
Function onCopy(sender As Object, event As Object)
Print($"Copy from {event["Control"]}")
End Function
Function onDelete(sender As Object, event As Object)
Print("Delete!")
End Function
app.AddLabel("lbl", 10, 10, {
"Text": "Right-click me!",
"ContextMenu": [
{"Text": "Copy", "Icon": "doc.on.doc", "OnClick": onCopy},
{"Text": "Paste", "Icon": "doc.on.clipboard", "OnClick": onPaste},
"-",
{"Text": "Delete", "Icon": "trash", "OnClick": onDelete}
]
})
| Key | Type | Description |
"Text" | String | Menu item label |
"Icon" | String | SF Symbol name (optional) |
"OnClick" | Function | Callback when item is clicked |
"-" | String | Use the string "-" as a separator between items |
Context menu callbacks receive event["Event"] = "ContextMenu", event["Value"] = menu item text, and event["Control"] = control name.
Shapes
All shapes use the same signature: Add*(name, x, y [, {options}]). Support FillColor, Gradient, Shadow, and OnClick callbacks.
| Method | Key Options | Description |
.AddRectangle() | "Width", "Height", "FillColor", "CornerRadius", "Gradient", "Shadow", "OnClick", "OnRightClick" | Filled rectangle |
.AddCircle() | "Radius", "FillColor", "Gradient", "Shadow", "OnClick", "OnRightClick" | Filled circle |
.AddLine() | "ToX", "ToY", "Color", "Width", "Style" | Line (no OnClick) |
Window Methods
| Method | Returns | Description |
.Show() | Object | Show window — modal if no callbacks, callback dispatch loop if any OnClick/OnChange |
.Close() | — | Close the window (call from callbacks to end dispatch loop) |
.GetControl(name) | Control | Get live control reference for property updates |
.SetTimer(name, ms, callback) | — | Start a named repeating timer. Callback fires every ms milliseconds |
.ClearTimer(name) | — | Stop and remove a named timer |
Timers
Use SetTimer / ClearTimer to run code periodically while the window is open. Timer callbacks run on the interpreter thread, same as UI callbacks — no threading issues. All timers are automatically stopped when the window closes.
Function onTick(sender As Object, event As Object)
app.GetControl("lblClock").Text = DateAndTime.Now().Format("HH:mm:ss")
End Function
// Update clock every second
app.SetTimer("clock", 1000, onTick)
// Stop the timer later
app.ClearTimer("clock")
Multiple timers can run simultaneously with different names and intervals. Replacing an existing timer (same name) automatically cancels the old one.
Multi-Window Support
Open multiple windows simultaneously. Call Form.Window() + Show() from inside a callback to open a secondary window. The first Show() blocks the interpreter; subsequent calls from callbacks register the new window and return immediately. All windows share a single event dispatch loop — callbacks from any window run on the same interpreter thread.
Var app As Object = Form.Window("Main Window", 500, 300)
Function openDetail(sender As Object, event As Object)
Var detail As Object = Form.Window("Detail", 300, 200)
detail.AddLabel("lbl", 15, 15, {"Text": "This is a second window!"})
detail.AddButton("btnOK", 15, 50, {
"Text": "Close Detail", "OnClick": onCloseDetail
})
detail.Show() // Does NOT block — registers into the shared event loop
End Function
Function onCloseDetail(sender As Object, event As Object)
// Find the detail window via a variable and close it
detail.Close()
End Function
app.AddButton("btnOpen", 15, 15, {
"Text": "Open Detail Window", "OnClick": openDetail
})
app.Show() // Blocks until ALL windows are closed
Rules:
- The first
Show() blocks until all windows are closed
- Subsequent
Show() calls (from callbacks) return immediately
Close() closes only that window — other windows stay open
- When the last window closes, the blocking
Show() returns
GetControl Properties
win.GetControl(name) returns a live control reference. Read and write properties at runtime:
| Property | Type | Read/Write | Description |
.Text | String | R/W | Text content (Label, Button, TextField, TextArea, ComboBox) |
.Value | Double / Date | R/W | Numeric value (Slider, ProgressBar) or DateAndTime object (DatePicker) |
.Items | Array | W | Update items list (ComboBox, ListBox, Table via 2D array) |
.Enabled | Boolean | R/W | Enable or disable a control |
.Visible | Boolean | R/W | Show or hide a control |
.SelectedRow | Integer | R/W | Selected row index for Table and ListBox (-1 = none). Set to programmatically select a row |
.Selected | Boolean | W | Check/uncheck state for CheckBox, RadioButton |
.Placeholder | String | W | Placeholder text for TextField |
.FontSize | Double | W | Font size (Label, TextField, TextArea) |
.FontBold | Boolean | W | Bold font (Label) |
.Icon | String | W | SF Symbol name (Button) |
.Image | Picture/String | W | Image from Picture object or file path (Canvas) |
.ForegroundColor | Color | W | Text color (Label, Button, TextField, TextArea) |
.SelectedTab | Integer | R/W | Active tab index for TabControl (0-based) |
// Select the first row in a table
app.GetControl("tblContacts").SelectedRow = 0
// Read selected row
Var row As Integer = app.GetControl("tblContacts").SelectedRow
// Deselect all rows
app.GetControl("tblContacts").SelectedRow = -1
Dialog Methods
Native macOS alert dialogs for quick user interaction:
| Method | Parameters | Returns | Description |
Form.Alert(message [, title]) | String, String | — | Show an informational message with OK button |
Form.Confirm(message [, title]) | String, String | Boolean | Show OK/Cancel dialog, returns True if OK clicked |
Form.Ask(message, buttons [, title]) | String, Array, String | String | Show dialog with custom buttons, returns clicked button text |
// Simple alert
Form.Alert("Contact saved successfully.")
// Confirm dialog
If Form.Confirm("Delete this contact?", "Confirm Delete") Then
db.Execute("DELETE FROM contacts WHERE id = ?", id)
End If
// Custom choice
Var choice As String = Form.Ask("Unsaved changes.", ["Save", "Discard", "Cancel"])
If choice = "Save" Then
saveData()
End If
Events & Callbacks
Add event callbacks to the options dict with a function reference. Callback signature: Function handler(sender As Object, event As Object).
sender: Name, Type, Value (plus all field values). event: Event, Control, Value. Shapes/Canvas also get X, Y (local coordinates).
Control Events
| Event | Fires when | Controls | event["Value"] |
OnClick | Control is clicked | Button, Label, Canvas, Rectangle, Circle | Button text, or null (shapes get X, Y) |
OnChange | Value changes (text fields: on blur) | TextField, TextArea, CheckBox, RadioButton, ComboBox, ListBox, Slider | Current value (text, boolean, double, or row index) |
OnDoubleClick | Row is double-clicked | ListBox, Table | Clicked row index (Integer) |
OnSelect | Selection changes | ListBox, Table | Selected row index (Integer, -1 if none) |
OnFocus | Control receives keyboard focus | TextField, TextArea | Current text content |
OnBlur | Control loses keyboard focus | TextField, TextArea | Current text content |
OnRightClick | Right mouse button clicked | Button, Canvas, Rectangle, Circle | null (shapes/canvas get X, Y) |
OnMouseMove | Mouse moves over control | Canvas | null (get X, Y from event) |
OnPaint | Canvas needs redrawing | Canvas | — |
Window Events
Set window events as properties: win.OnLoad = myFunction
| Event | Fires when | Description |
OnLoad | Window is displayed | Fires once after Show() — use to initialize controls or load data |
OnClose | Window is closing | Fires when the window close button is pressed — use for cleanup |
OnResize | Window is resized | Fires when the user resizes the window — use to reposition controls |
Chart
Create bar, line, pie, and scatter charts.
| Method | Parameters | Returns | Description |
Bar(labels, values) | Array, Array | ChartObject | Create bar chart |
Line(labels, values) | Array, Array | ChartObject | Create line chart |
Pie(labels, values) | Array, Array | ChartObject | Create pie chart |
Scatter(labels, values) | Array, Array | ChartObject | Create scatter chart |
ChartObject
| Property/Method | Description |
.Title | Chart title (read/write) |
.SetSize(w, h) | Set chart dimensions |
.SetColor(r, g, b) | Set chart color (RGB integers 0–255) |
.Show() | Display in a window |
.SaveToFile(path) | Save chart as PNG |
.ToPicture() | Convert to Picture object |
Graphics
Create and manipulate images with drawing operations.
| Method | Parameters | Returns | Description |
CreatePicture(width, height [, transparent]) | width, height, transparent (optional Boolean) | Picture | Create a blank image. Default: white background. If transparent is True, the background is transparent (for overlays) |
Picture Object
| Method | Parameters | Description |
.DrawRectangle(x, y, w, h) | x, y, width, height | Draw rectangle outline |
.FillRectangle(x, y, w, h) | x, y, width, height | Fill rectangle |
.DrawEllipse(x, y, w, h) | x, y, width, height | Draw ellipse outline |
.FillEllipse(x, y, w, h) | x, y, width, height | Fill ellipse |
.DrawLine(x1, y1, x2, y2) | start x/y, end x/y | Draw a line |
.DrawText(text, x, y) | text, x, y | Draw text |
.DrawPicture(pic, x, y) | picture, x, y | Overlay another picture |
.SetColor(color) | Color or r,g,b | Set stroke color |
.SetFillColor(color) | Color or r,g,b | Set fill color |
.SetLineWidth(w) | width | Set line thickness |
.SetFont(name, size) | font name, size | Set text font |
.SaveToFile(path) | file path | Save as PNG |
.ToPicture() | — | Get as Picture value |
.DetectText([lang]) | [language] | Detect text via Vision (AI) |
.DetectObjects() | — | Detect objects via Vision (AI) |
.DetectFaces() | — | Detect faces via Vision (AI) |
Screen
Screen information, mouse position, and screenshots.
| Method | Parameters | Returns | Description |
Width() | — | Integer | Main screen width |
Height() | — | Integer | Main screen height |
ScaleFactor() | — | Double | Retina scale factor |
DarkMode() | — | Boolean | Is dark mode active |
Displays() | — | Array | All connected displays |
MouseX() | — | Integer | Mouse X position |
MouseY() | — | Integer | Mouse Y position |
Screenshot() | — | Picture | Capture entire screen |
ScreenshotRegion(x, y, w, h) | x, y, w, h | Picture | Capture screen region |
ScreenshotToFile(path) | file path | Boolean | Save screenshot to file |
PixelColor(x, y) | x, y | Color | Get pixel color |
PDF
Create and manipulate PDF documents.
| Method | Parameters | Returns | Description |
Create([width, height]) | [w, h] | PDF | Create new PDF |
Open(path) | file path | PDF | Open existing PDF |
PDF Object
| Method | Parameters | Description |
.AddPage([w, h]) | [width, height] | Add a new page |
.SetFont(name, size) | font, size | Set text font |
.DrawText(x, y, text) | x, y, text | Draw text on page |
.SaveToFile(path) | path | Save PDF to file |
.AddPageNumbers([format]) | [format] | Add page numbers |
QRCode
Generate and read QR codes.
| Method | Parameters | Returns | Description |
Generate(text [, size]) | content [, pixel size] | Picture | Generate QR code image |
Read(picture) | picture | String | Read QR code from Picture object |
Translate
Text translation using Apple Translation or MyMemory API.
| Method | Parameters | Returns | Description |
Text(text, targetLang [, sourceLang]) | text, target lang [, source lang] | String | Translate text (source language is optional) |
DetectLanguage(text) | text | String | Detect language of text |
DetectLanguages(text [, count]) | text [, max results] | Array | Detect multiple possible languages |
Encoding
Base64, hex, URL encoding, and number base conversions.
| Method | Parameters | Returns | Description |
Base64Encode(text) | text | String | Encode to Base64 |
Base64Decode(text) | Base64 string | String | Decode from Base64 |
HexEncode(text) | text | String | Encode to hex |
HexDecode(text) | hex string | String | Decode from hex |
URLEncode(text) | text | String | URL-encode text |
URLDecode(text) | encoded text | String | URL-decode text |
HTMLEscape(text) | text | String | Escape HTML entities |
HTMLUnescape(text) | text | String | Unescape HTML entities |
ToBinary(n) | integer | String | Convert to binary string |
FromBinary(text) | binary string | Integer | Parse binary string |
ToOctal(n) | integer | String | Convert to octal |
FromOctal(text) | octal string | Integer | Parse octal string |
ToHex(n) | integer | String | Convert to hex |
FromHex(text) | hex string | Integer | Parse hex string |
ToBase(n, base) | number, base | String | Convert to arbitrary base |
FromBase(text, base) | string, base | Integer | Parse from arbitrary base |
Char(code) | ASCII code | String | Character from code point |
ASCII(char) | character | Integer | Code point of character |
Speech
Text-to-speech using the system voice.
| Method | Parameters | Returns | Description |
Say(text [, voice]) | text [, voice name] | — | Speak text aloud |
GetVoices() | — | Array | List available voices |
SetVoice(name) | voice name | — | Set default voice |
SetRate(rate) | speed (0–300) | — | Set speech rate |
Stop() | — | — | Stop speaking |
Clipboard
System clipboard access.
| Method | Parameters | Returns | Description |
GetText() | — | String | Read clipboard text |
SetText(text) | text | — | Copy text to clipboard |
HasText() | — | Boolean | Check if clipboard has text |
Clear() | — | — | Clear clipboard |
DateAndTime
Date and time creation, formatting, and arithmetic.
| Method | Parameters | Returns | Description |
Now() | — | Date | Current date and time |
Today() | — | Date | Today at midnight |
Timestamp() | — | Integer | Unix timestamp (seconds) |
TimestampMillis() | — | Integer | Unix timestamp (milliseconds) |
Create(y, m, d [, h, min, s]) | year, month, day [, ...] | Date | Create specific date |
Parse(text, format) | string, format | Date | Parse date from string |
DaysBetween(d1, d2) | date, date | Integer | Days between two dates |
SecondsBetween(d1, d2) | date, date | Integer | Seconds between two dates |
IsLeapYear(year) | year | Boolean | Check if leap year |
DaysInMonth(year, month) | year, month | Integer | Days in given month |
Date Object
| Property/Method | Type | Description |
.Year, .Month, .Day | Integer | Date components |
.Hour, .Minute, .Second | Integer | Time components |
.DayOfWeek | Integer | Day of week (1=Sun) |
.DayOfWeekName | String | Day name (e.g. "Monday") |
.MonthName | String | Month name (e.g. "January") |
.AddDays(n) | Date | Add days |
.AddHours(n) | Date | Add hours |
.AddMinutes(n) | Date | Add minutes |
.AddMonths(n) | Date | Add months |
.AddYears(n) | Date | Add years |
.Format(fmt) | String | Format as string (e.g. "yyyy-MM-dd") |
.ToString() | String | Default string representation |
Calendar
Access macOS Calendar events and Reminders.
| Method | Parameters | Returns | Description |
Today() | — | Array | Today's events |
Events(from, to) | start date, end date | Array | Events in date range |
NextEvent() | — | Event | Next upcoming event |
Busy(date) | date | Boolean | Check if date has events |
CreateEvent(options) | Object | Event | Create a calendar event |
DeleteEvent(event) | event | Boolean | Delete an event |
List() | — | Array | List all calendars |
Reminders() | — | Array | Get all reminders |
CreateReminder(options) | Object | Reminder | Create a reminder |
Crypto
Cryptographic hashing, HMAC, and encryption.
| Method | Parameters | Returns | Description |
SHA256(text) | text | String | SHA-256 hash |
SHA384(text) | text | String | SHA-384 hash |
SHA512(text) | text | String | SHA-512 hash |
HMAC_SHA256(text, key) | text, key | String | HMAC-SHA256 |
HMAC_SHA512(text, key) | text, key | String | HMAC-SHA512 |
VerifyHMAC(text, key, hash) | text, key, expected | Boolean | Verify HMAC |
GenerateKey() | — | String | Generate AES-GCM key |
Encrypt(text, key) | plaintext, key | String | AES-GCM encrypt |
Decrypt(text, key) | ciphertext, key | String | AES-GCM decrypt |
EncryptChaCha(text, key) | plaintext, key | String | ChaCha20-Poly1305 encrypt |
DecryptChaCha(text, key) | ciphertext, key | String | ChaCha20-Poly1305 decrypt |
RandomToken(length) | byte length | String | Random hex token |
HashFile(path) | file path | String | SHA-256 hash of file |
AI
AI text generation via Apple Intelligence, Claude, Google, or OpenAI.
| Method | Parameters | Returns | Description |
Apple() | — | AppleAI | Apple Intelligence (on-device) |
Claude([apiKey [, model]]) | [key, model] | ClaudeAI | Anthropic Claude |
Google([apiKey [, model]]) | [key, model] | GoogleAI | Google Gemini |
OpenAI([apiKey [, model]]) | [key, model] | OpenAI | OpenAI GPT |
AI Provider Object
| Method | Parameters | Returns | Description |
.Generate(prompt) | prompt text | String | Generate text |
.GenerateWith(system, prompt) | system prompt, user prompt | String | Generate with system instruction |
.Summarize(text) | text | String | Summarize text |
.Translate(text, lang) | text, target language | String | Translate text |
.IsAvailable() | — | Boolean | Check availability (Apple only) |
Audio
Audio playback and recording.
| Method | Parameters | Returns | Description |
LoadSound(path) | file path | AudioPlayer | Load audio file |
StartRecording(path) | output path | AudioRecorder | Start recording audio |
AudioPlayer Object
| Method/Property | Description |
.Play() | Start playback |
.Pause() | Pause playback |
.Resume() | Resume playback |
.Stop() | Stop playback |
.Seek(seconds) | Seek to position |
.SetVolume(level) | Set volume (0.0–1.0) |
.SetLooping(bool) | Enable/disable looping |
.GetDuration() | Get total duration |
.GetPosition() | Get current position |
.Release() | Release resources |
.IsPlaying | Whether currently playing |
.Duration | Total duration in seconds |
Synth
Synthesizer for generating tones and sounds.
| Method | Parameters | Returns | Description |
PlayNote(freq [, duration]) | frequency [, seconds] | — | Play a single note |
PlaySequence(notes, duration) | freq array, seconds | — | Play a sequence of notes |
SweepUp(startHz, endHz, duration) | start freq, end freq, seconds | — | Play ascending frequency sweep |
SweepDown(startHz, endHz, duration) | start freq, end freq, seconds | — | Play descending frequency sweep |
Noise(duration) | seconds | — | Play white noise |
Stop() | — | — | Stop all playback |
SetVolume(level) | volume (0.0–1.0) | — | Set output volume |
SetAttack(seconds) | seconds | — | Set attack time |
SetDecay(seconds) | seconds | — | Set decay time |
SetSustain(level) | level (0.0–1.0) | — | Set sustain level |
SetRelease(seconds) | seconds | — | Set release time |
Notification
macOS system notifications.
| Method | Parameters | Returns | Description |
Send(title, message [, sound]) | title, body [, sound name] | — | Show system notification |
SendWithSubtitle(title, subtitle, msg) | title, subtitle, body | — | Notification with subtitle |
Hardware
System hardware information.
| Method | Parameters | Returns | Description |
CPU() | — | Object | CPU info (Model, Cores, PhysicalCores) |
Memory() | — | Object | RAM info (Total, Available, Used, Pressure) |
Battery() | — | Object | Battery (Level, IsCharging, PowerSource, CycleCount) |
Disk() | — | Object | Boot disk (Total, Free, Used) |
DiskFor(path) | path | Object | Disk info for path |
Uptime() | — | Integer | System uptime in seconds |
ThermalState() | — | String | Thermal state (Nominal/Fair/Serious/Critical) |
MacModel() | — | String | Mac model identifier |
Displays() | — | Array | Connected displays |
Bluetooth
Bluetooth Low Energy (BLE) device scanning and communication.
| Method | Parameters | Returns | Description |
IsAvailable() | — | Boolean | Check if Bluetooth is on |
Scan(seconds) | duration | Array | Scan for BLE devices |
Connect(device) | device object | Connection | Connect to device |
Disconnect(connection) | connection | Boolean | Disconnect from device |
Connection Object
| Method | Parameters | Description |
.Discover() | — | Discover services & characteristics |
.Read(serviceUUID, charUUID) | UUIDs | Read characteristic value (hex) |
.Write(serviceUUID, charUUID, hex) | UUIDs, hex data | Write to characteristic |
.Disconnect() | — | Disconnect |
Location
GPS location and geocoding.
| Method | Parameters | Returns | Description |
Current() | — | Location | Get current GPS location |
SearchAddress(address) | address string | Location | Geocode address to coordinates |
SearchCoordinates(lat, lon) | lat, lon | Location | Reverse geocode |
DistanceBetween(lat1, lon1, lat2, lon2) | coords | Double | Distance in meters |
BearingBetween(lat1, lon1, lat2, lon2) | coords | Double | Bearing in degrees |
Access macOS Contacts.
| Method | Parameters | Returns | Description |
Search(query) | search text | Array | Search contacts by name |
SearchByEmail(email) | email | Array | Find by email |
SearchByPhone(phone) | phone | Array | Find by phone |
All() | — | Array | Get all contacts |
Count() | — | Integer | Total number of contacts |
Create(firstName, lastName) | first, last | Contact | Create a new contact |
Groups() | — | Array | List contact groups |
VCard(contact) | contact | String | Export as vCard |
Color
Color creation and manipulation.
Preset Colors
Color.Red, Color.Green, Color.Blue, Color.White, Color.Black, Color.Yellow, Color.Orange, Color.Purple, Color.Cyan, Color.Magenta, Color.Gray, Color.Pink, Color.Brown, Color.Gold, Color.Silver, Color.Navy, Color.Teal, Color.Coral
Methods
| Method | Parameters | Returns | Description |
RGB(r, g, b) | 0–255 each | Color | Create from RGB |
RGBA(r, g, b, a) | 0–255, alpha 0–1 | Color | Create from RGBA |
Hex(hex) | hex string | Color | Create from hex (e.g. "#FF0000") |
HSL(h, s, l) | hue, saturation, lightness | Color | Create from HSL |
Mix(c1, c2) | color, color | Color | Mix two colors |
Lighten(color, amount) | color, 0–1 | Color | Lighten a color |
Darken(color, amount) | color, 0–1 | Color | Darken a color |
Shell
Execute system commands.
| Method | Parameters | Returns | Description |
Execute(command) | command string | Object | Run shell command; returns {Output, ErrorOutput, ExitCode} |